/*eslint-disable */
export default function (fn, delay, mustRunDelay) {
	var timer = null;
	var tStart;

	return function () {
		var context = this, args = arguments, tCurr = + new Date();

		clearTimeout(timer);

		if(!tStart){
			tStart = tCurr;
		}

		if(tCurr - tStart >= mustRunDelay){
			fn.apply(context, args);
			tStart = tCurr;
		} else {
			timer = setTimeout(function(){
				fn.apply(context, args);
			}, delay);
		}
	};
}
